<template>
  <div>
    <p v-blink>本段内容会闪烁</p>
    <hr>
  </div>
</template>

<script setup>
const vBlink = {
  mounted (el) {
    let isVisible = true;
    let colors = ['#FFC312','#C4E538','#EE5A24','#D980FA','#12CBC4','#ED4C67']
    setInterval (() => {
      let fontColor = colors[Math.round(Math.random() * colors.length)]
      let bgColor = colors[Math.round(Math.random() * colors.length)]
      isVisible = !isVisible;
      el.style.color = fontColor
      el.style.backgroundColor = bgColor
      el.style.visibility = isVisible ? "visible" : "hidden";
    },1000)
  }
}
</script>

<style scoped>

</style>